/**
 * @description:
 * @Author: wuzhenbin
 * @CreateTime: 2025/2/16
 */
public class leetcode_55 {
    public static void main(String[] args) {
        int[] ints = {3, 2, 1, 0, 4};
        System.out.println(canJump(ints));
    }

    public static boolean canJump(int[] nums) {
        //贪心的精髓  ----》一个全局的最优解  每次都单步选择局部最优解逼近这个全局最优解
        int maxCanReach = 0;
        for (int i = 0; i < nums.length-1; i++) {
            maxCanReach = Math.max(maxCanReach, i + nums[i]);
        }
        if (maxCanReach >= nums.length) return true;
        return false;
    }
}
